//
//  RBPwdIcon.m
//  4-26-1 手势密码改进
//
//  Created by 华杨科技 on 2017/4/26.
//  Copyright © 2017年 饶波. All rights reserved.
//
//  手势密码头像view
#import "RBPwdIcon.h"
#import "RBPwdHeader.h"
@implementation RBPwdIcon

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self initSubviews];
        
    }
    return self;
}

#pragma mark 1.用于设置frame
- (void)layoutSubviews {

    /*
    CGPoint centerP =  self.center;
    CGFloat x = centerP.x;
    CGFloat y = centerP.y;
    
    
    self.iconIV.frame = CGRectMake(0,0, ICONWH, ICONWH);
//    self.iconIV.center = CGPointMake(x, y);
    self.iconIV.center = self.center;
    NSLog(@"%@",NSStringFromCGPoint(self.center));

    self.nameLB.frame = CGRectMake(0,0, 150, 21);
    self.nameLB.center = CGPointMake(x, y);
    
    self.reminderLB.frame = CGRectMake(0, 0, 200, 50);
    self.reminderLB.center = CGPointMake(x, y);
    */
    CGRect frame = self.frame;
    CGFloat w = frame.size.width;
    CGFloat iconX = (w - ICONWH) / 2;
    self.iconIV.frame = CGRectMake(iconX, ICONSpace, ICONWH, ICONWH);

    CGFloat nameX = (w - ICON_Name_W)/2;
    CGFloat nameY = 2*ICONSpace + ICONWH ;
    self.nameLB.frame = CGRectMake(nameX, nameY, ICON_Name_W, ICON_Name_H);
    
    CGFloat reminderX = (w - ICON_Reminder_W) / 2;
    CGFloat reminderY = 3*ICONSpace + ICONWH + ICON_Name_H;
    self.reminderLB.frame = CGRectMake(reminderX, reminderY, ICON_Reminder_W, ICON_Reminder_H);
    
}

#pragma mark 2.初始化subviews
- (void)initSubviews {
    [self addSubview:self.iconIV];
    [self addSubview:self.nameLB];
    [self addSubview:self.reminderLB];
}

#pragma mark 3.setter方法
- (UIImageView *)iconIV {
    if (!_iconIV) {
        _iconIV = [[UIImageView alloc] init];
        _iconIV.clipsToBounds = YES;
        _iconIV.layer.cornerRadius = ICONWH / 2;
        _iconIV.backgroundColor = [UIColor yellowColor];
    }
    return _iconIV;
}

- (UILabel *)nameLB {
    if (!_nameLB) {
        _nameLB = [[UILabel alloc] init];
        _nameLB.textAlignment = NSTextAlignmentCenter;
        _nameLB.font = [UIFont systemFontOfSize:18.0];
        _nameLB.backgroundColor = [UIColor brownColor];
    }
    return _nameLB;
}

- (UILabel *)reminderLB {
    if (!_reminderLB) {
        _reminderLB = [[UILabel alloc] init];
        _reminderLB.textAlignment = NSTextAlignmentCenter;
        _reminderLB.numberOfLines = 0;
//        _reminderLB.backgroundColor = [UIColor cyanColor];
        _reminderLB.textColor = [UIColor whiteColor];
        _reminderLB.font = [UIFont systemFontOfSize:14.0];
    }
    return _reminderLB;
}
@end
